<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>华为手机商城</title>
	<link rel="stylesheet" href="../../static/shopping/css/style.css">
	<script src="../../static/shopping/js/jquery-1.8.3.min.js"></script>
      <script src="../../static/shopping/js/banner.js"></script>
</head>
<body>
	<div class="top1">
        <a href="${pageContext.request.contextPath}/toIndex">首页</a>
        <a href="https://consumer.huawei.com/cn/">华为官网</a>
        <a href="https://www.honor.cn/">荣耀官网</a>
        <a href="https://club.huawei.com/">花粉俱乐部</a>
        <a href="#">V码（优购码）</a>
        <a href="https://company.vmall.com/">企业购</a>
        <a href="#">Select Region</a>
        <a href="#">更多精彩</a>
        <span>

        <c:if test="${sessionScope.user==null}">
            <a href="${pageContext.request.contextPath}/toLogin">你好,请登录</a>
            <a href="${pageContext.request.contextPath}/toRegister">注册</a>
        </c:if>

        <c:if test="${sessionScope.user!=null}">
             <a href="">欢迎回来! ${sessionScope.users.account}</a>
             <a href="${pageContext.request.contextPath}/toLogin">退出</a>
             <a href="#">我的订单</a>
        </c:if>
               <a href="#">客户服务</a>
               <a href="#">网站导航</a>
               <a href="#">手机版</a>
               <a href="${pageContext.request.contextPath}/toCart_list">购物车</a>
           </span>
	</div>
	<div class="nav w">
		<ul>
			<li><img src="../../static/shopping/images/logo.png" alt=""><img src="../../static/shopping/images/tb1.png" alt=""><img src="../../static/shopping/images/tb2.png" alt=""></li>
			<li>
          <a href="${pageContext.request.contextPath}/toShop_list">商品展示页</a>
          <a href="${pageContext.request.contextPath}/getShop_hot">商品热销推荐页</a>
<%--          <a href="${pageContext.request.contextPath}/toCart_list">购物车页</a>--%>
<%--          <a href="${pageContext.request.contextPath}/toRegister">注册页</a>--%>
<%--          <a href="${pageContext.request.contextPath}/toLogin">登录页</a>--%>
      </li>
		</ul>
	</div>
	<hr>
	<div class="dh w">
		<h5>首页　>　手机</h5>
        <ul>
    <li>分类：<a href="javascript:;">手机</a></li>
    <li>服务优惠：<a href="javascript:;" class="checkbox">仅看有货&nbsp;&nbsp;分期免息</a></li>
    <li>屏幕尺寸：<a href="javascript:;">6.0-6.5英寸&nbsp;&nbsp;6.5英寸以上</a></li>
    <li>更多选项：<a href="javascript:;">运行内存&nbsp;&nbsp;存储容量&nbsp;&nbsp;上市时间</a></li>
    <li>排序：<span>综合</span> <a href="javascript:;">最新&nbsp;&nbsp;评论数&nbsp;&nbsp;价格</a></li>
        </ul>
	</div>
	<div class="cp w">
       <ul>
        <c:forEach items="${phonesInfo}" var="phonesInfo">
       	<li>
       		<img src="../../static/shopping/images/${phonesInfo.url}" alt="">
       		<h4>${phonesInfo.name}</h4><p>${phonesInfo.jieshao}</p>¥<span class="price_one">${phonesInfo.price}</span>
       		<div class="di">
       			<a href="javascript:;" onclick="add_card(${phonesInfo.id})" style="width: 80px;height: 30px;line-height: 30px; text-align: center; background: red;color:#fff;display: block;margin-top: 1px;">添加购物车</a>
       		</div>
       	</li>
           </c:forEach>
       </ul>
</div>
<script>
    function add_card(id) {
        var data = {pid:id}
        $.ajax({
            url: "/add_card",
            data: data,
            type: "POST",
            success: function (result) {
                var res = JSON.stringify(result)
                console.log(res);

                if(res == 1){
                    alert('添加成功')
                }else if(res == 2){
                    alert('已经添加')
                }
            }
        })
    }
</script>
<div class="footer">
    <p>制作团队：晚睡协会</p>
</div>
</body>
</html>